﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CommonData;

namespace DataCentral.Forms
{
    public partial class DebtSumForm : CommonData.CommonChildForm
    {
        public DebtSumForm()
        {
            InitializeComponent();
        }

        private void DebtSumForm_Load(object sender, EventArgs e)
        {
            dtpFromDate.DateTime = DateTime.Now;
            dtpToDate.DateTime = DateTime.Now;
            ValueListClass clValueList = new ValueListClass();
            iluCustomer.DataSource = clValueList.GetCustomerList();
            iluSalePerson.DataSource = clValueList.GetSaleSysPersonList();
            rdgDebtType_SelectedIndexChanged(null, null);
        }

        private void rdgDebtType_SelectedIndexChanged(object sender, EventArgs e)
        {
            CommonDataAccess cmDataAccess = new CommonDataAccess();
            List<ParameterObject> lstParams = new List<ParameterObject>();
            lstParams.Add(new ParameterObject("@FromDate", dtpFromDate.DateTime.Date));
            lstParams.Add(new ParameterObject("@ToDate", dtpToDate.DateTime.Date));
            gridDebtSum.DataSource = rdgDebtType.SelectedIndex == 0 ?
                cmDataAccess.GetDataTableBySproc("DATA_GetDebtSumBySalePerson", lstParams) :
                cmDataAccess.GetDataTableBySproc("DATA_GetDebtSumByCustomer", lstParams);
            colRoundID.Visible = rdgDebtType.SelectedIndex ==0;
            colCustomerID.Visible = rdgDebtType.SelectedIndex == 1;
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            rdgDebtType_SelectedIndexChanged(null, null);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
